﻿using SimonGame.Logic;
using SimonGame.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using static SimonGame.Enum.LightEnum;

namespace SimonGame
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        RoundColorLogic roundColor;
        PlaySimonGameViewModel viewModel;
       

        private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Light currentLight = GetLight(sender);
            roundColor.Click(currentLight);
        }


        private Light GetLight(object sender)
        {
            var img = sender as Image;
            if (img == null)
                return Light.None;
            return (Light)System.Enum.Parse(typeof(Light), img.Tag.ToString());
        }

        private void Replay_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            roundColor.Start();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            viewModel = new PlaySimonGameViewModel();
            this.DataContext = viewModel;
            roundColor = new RoundColorLogic(viewModel);
            roundColor.Start();
        }
    }
}
